package Threads;

import java.util.List;
import java.util.Random;

public class ThreadRunnable extends Thread
{

    private int Generate(int range) {
        Random rand = new Random();
        int randomInt = rand.nextInt(range);
        return randomInt;
    }
    protected int progres;
    protected List<Integer> list;
    protected boolean proces = true;

    public ThreadRunnable(int status, List<Integer> list) {
        this.progres = status;
        this.list = list;
    }

    public void Status(boolean proces) {
        this.proces = proces;
    }

    @Override
    public void run() {
        try {
            while (proces) {
                int number = Generate(progres);
                list.add(number);
                System.out.println("число в массив: " + number);
                Thread.sleep(2000);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
